Imports System.Windows.Forms

Public Class frmUserSecurity

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Try
            If MsgBox("Save changes?", MsgBoxStyle.YesNo, "Save") = MsgBoxResult.Yes Then
                SaveChanges()
            End If            
        Catch ex As Exception
            DisplayErrors(ex)
        End Try
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()    
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Sub SaveChanges()
        Try
            Cursor = Cursors.WaitCursor
            Dim oSec As New UserSecurity
            oSec.Save(dgUserSecurity.DataSource)
        Catch ex As Exception
            DisplayErrors(ex)
        End Try
        Cursor = Cursors.Default
    End Sub

    Private Sub frmUserSecurity_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim oSec As New UserSecurity
            Dim dt As DataTable
            dt = oSec.GetAll()
            dgUserSecurity.DataSource = dt

            'dgUserSecurity.Columns("UserID").ReadOnly = True
        Catch ex As Exception
            DisplayErrors(ex)
        End Try
    End Sub
End Class
